"""
位运算操作符
"""


def testBitOperator():
    # AND 与
    # 同1则1，不然为0
    # 2 = 0b0010
    # 3 = 0b0011
    print("2 & 3 = {}".format(2 & 3))

    # OR 或
    # 有1则1，同0为0
    # 4 = 0b0100
    # 3 = 0b0011
    print ("4 | 3 = {}".format(4 | 3))

    # NOT 非
    # 0变1，1变0
    # 3 = 0b0011
    print ("~3 = {}".format(~3))

    # XOR 异或
    # 不同为1，相同为0
    # 5 = 0b0101
    # 3 = ob0011
    print("5 ^ 3 = {}".format(5 ^ 3))

    # 左移 <<
    # 5 = 0b0101
    print("5 << 1 = {}".format(5 << 1))
    print("5 << 2 = {}".format(5 << 2))

    # 右移 >>
    # 5 = 0b0101
    print("5 >> 1 = {}".format(5 >> 1))

testBitOperator()